package com.finace.money.ui.activity;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.finace.money.R;
import com.finace.money.common.util.StringUtil;
import com.finace.money.common.util.UIUtil;
import com.finace.money.di.component.AppComponent;

import butterknife.BindView;

/**
 * Created by zhangpeng on 2018/1/26.
 */

public class TextInfoActivity extends BaseActivity implements View.OnClickListener {
    @BindView(R.id.rl_left)
    RelativeLayout rlLeft;
    @BindView(R.id.tv_head_title)
    TextView tvHeadTitle;
    @BindView(R.id.tv_content)
    TextView tvContent;
    @BindView(R.id.button_sure)
    Button buttonSure;
    private String mDealFlag;
    private String phone;
    private String code;
    private String imgcode;

    @Override
    public int setLayout() {
        return R.layout.activity_text_info;
    }

    @Override
    public void init() {
        rlLeft.setOnClickListener(this);
        buttonSure.setOnClickListener(this);

        mDealFlag = getIntent().getStringExtra("deal");
        phone = getIntent().getStringExtra("phone");
        code = getIntent().getStringExtra("code");
        imgcode = getIntent().getStringExtra("imgcode");
        if (StringUtil.isNotNullString(mDealFlag)) {
            tvHeadTitle.setText(R.string.cooperation_agreement);//合作协议
            buttonSure.setText(R.string.agreement_agree);
            tvContent.setText(R.string.agreement);
        } else {
            tvHeadTitle.setText(R.string.deal_risk_book);
            buttonSure.setText(R.string.risk_know);
            tvContent.setText(R.string.risk);
        }
    }

    @Override
    public void setupAcitivtyComponent(AppComponent appComponent) {

    }

    @Override
    public void onClick(View view) {

        switch (view.getId()) {
            case R.id.rl_left:
                onBackPressed();
                break;
            case R.id.button_sure:
                if (StringUtil.isNotNullString(mDealFlag)) {
                    Intent intent = new Intent(UIUtil.getContext(), InformationActivity.class);
                    intent.putExtra("phone",phone);
                    intent.putExtra("code",code);
                    intent.putExtra("imgcode",imgcode);
                    startActivity(intent);
                } else {
                    Intent intent = new Intent(UIUtil.getContext(), TextInfoActivity.class);
                    intent.putExtra("deal", "deal");
                    intent.putExtra("phone",phone);
                    intent.putExtra("code",code);
                    intent.putExtra("imgcode",imgcode);
                    startActivity(intent);
                }
                finish();
                break;
        }
    }
}
